package net.jjjshop.common.mapper.lbt;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.jjjshop.common.entity.lbt.JybTradeOrderEntity;
import net.jjjshop.common.entity.lbt.LbTransferRecordEntity;
import net.jjjshop.common.entity.lbt.LbTzPriceEntity;
import net.jjjshop.common.entity.lbt.LbUserWalletEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;

/**
 * 用户转账记录表 DAO 映射层
 */
@Mapper
public interface LbTransferRecordMapper extends BaseMapper<LbTransferRecordEntity> {
    /**
     * 查询转账记录
     * @param uid 查询用户转出
     * @param receiveAccount 查询收款用户记录
     * @return
     */
    IPage<LbTransferRecordEntity> queryList(Page<JybTradeOrderEntity> pages,Integer uid, String receiveAccount);

    /**
     * 查询昨日波比总额
     * @return
     */
    @Select("SELECT SUM(number) FROM eb_user_bill WHERE type ='101' and pm ='1' and  LEFT(create_time,10)=DATE_SUB(curdate(),INTERVAL 1 DAY)")
    BigDecimal yestDayAll();

    /**
     * 查询可释放金币用户
     * @return
     */
    @Select("SELECT * from lb_user_wallet a LEFT JOIN eb_user b on a.uid = b.uid WHERE b.order_num >0 and a.score_freeze >0")
    List<LbUserWalletEntity> getUserList();

    /**
     * 新增价格
     * @param bean
     * @return
     */
    Integer addTzPrice(LbTzPriceEntity bean);

    List<LbTzPriceEntity> selectTzPrice(Integer limit);

    /**
     * 求和
     * @return
     */
    @Select("SELECT sum(score) from lb_user_wallet")
    BigDecimal addScore();

}
